/**
 *
 *  @auth xlx_good@qq.com
 *  @date 17/6/21.
 *
 */

requirejs.config({
    baseUrl: '../../',
    paths:  {
        avalon: 'javascript/avalon.min',
        jquery: 'js/plugins/jquery/jquery-2.1.1.min',
        pagination: 'lib/pagination/jquery.pagination',
        WdatePicker: 'js/plugins/DatePicker/WdatePicker',
        config: 'javascript/config',
        api: 'javascript/api',
        layer: 'js/plugins/layer1/layer',
        arg: 'javascript/arg'
    },
    shim: {
        pagination: {
            deps: ['jquery']
        },
        api: {
            deps: ['jquery']
        },
        layer: {
            deps: ['jquery']
        }
    }
});


(function(win, dom, requirejs, initVm){
    var vm;
    requirejs(['avalon', 'jquery', 'pagination', 'WdatePicker', 'config', 'api', 'layer', 'arg'], function(){
        //初始化vm
        vm = initVm(dom);
		WdatePicker();
    });

})(window, document, requirejs, function(dom){
    var vm = avalon.define({
        $id: 'container',
        form: {
            startTime: '',
            endTime: ''
        },
		list: [],
        search: function(){
			Api.reportDailysalePage(vm.form, function(resp) {
				if(resp.code == 0) {
					vm.list = resp.data;
				} else {
					layer.msg(resp.msg);
				}
			});
        }

    })
	avalon.filters.filterOption = function(item) {
		var params = {
			date: item.time
		}
		return '<a href="'+Arg.url("./sale.html", params)+'">详情</a>';
	}
    avalon.scan(dom.body);
    return vm;
});
